home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1558 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  51 lines

  1. Path: news.voicenet.com!news
  2. From: kobak@voicenet.com (Peter Kobak)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Why can't I use this function prototype????
  5. Date: 11 Jan 1996 16:58:32 GMT
  6. Organization: Voicenet - Internet Access - (215)674-9290
  7. Message-ID: <4d3fjo$j5v@news.voicenet.com>
  8. NNTP-Posting-Host: philly218.voicenet.com
  9. X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
  10.  
  11. In message <60ju5934@kbrady.ultranet.com> - Ken Brady <kbrady@ultranet.com> 
  12. writes:
  13. :>/*  pm_app.hpp */ 
  14. :>Class PmApplication { 
  15. :>  PmApplication();
  16. :>  .... //member and method definitions here 
  17. :>}; 
  18. :> 
  19. :>PmApplication *Application();    //a typical function prototype?? 
  20. :>// other function prototypes here 
  21. :>// end pm_app.hpp 
  22. :> 
  23. :>The compiler error is: 
  24. :>myapp.cpp(53): Error! E043: (col 1) static function 'Application' has   
  25. :>not been defined  
  26. :>myapp.cpp(53): Note! N392: (col 1) 'PmApp * Application( void )'   
  27. :>defined in: d:\c\lib\pm_app.hpp(55) (col 15)  
  28.  
  29. Your compiler is reporting a PmApp * Application() on the 'Note!', not a 
  30. PmApplication * Application(). Is the return type name wrong in your .hpp 
  31. file, despite what you posted as it's contents?
  32.  
  33. :>I've tried implementing the global variable directly, i.e., defining   
  34. :>the global variable 'PmApplication *App=NULL' in the header file.    
  35. :>Then, the linker tells me that it has redefined App for every file that   
  36. :>includes pm_app.hpp.  How else can I implement a global variable? 
  37.  
  38. Declare the global in your header (.hpp) file:
  39.    extern PmApplication * App;
  40.  
  41. Define the global in your implementation (.cpp) file:
  42.    PmApplication * App = NULL;
  43.  
  44. This is just C stuff; no complication added because of C++.
  45.  
  46. ================
  47. Peter Kobak
  48. kobak@voicenet.com
  49.  
  50.  
  51.